package com.thumb.servlet;

import com.thumb.bean.Thumb;
import com.thumb.service.impl.ThumbServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @Author: Spider Man
 * @Description:
 * @Date Created in 2020-09-08 14:08
 * @Modified By:
 */

@WebServlet(value = "/thumb")
public class ThumbServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ThumbServiceImpl thumbService = new ThumbServiceImpl();
        List<Thumb> number = thumbService.findNumber();
        int data = 0;
        for (Thumb thumb : number) {
            data = thumb.getNumber();
        }
        thumbService.updateNumber(data,++data);
        PrintWriter writer = resp.getWriter();
        writer.print(data);
    }
}
